import { _decorator, Component, Node } from 'cc';
import GlobalPool from '../../Init/Tools/GlobalPool';
import { BuffCd } from './BuffCd';
const { ccclass, property } = _decorator;

@ccclass('BuffLayer')
export class BuffLayer extends Component {

    _recs: BuffCd[] = [];
    onLoad() {
        this.setBuffIco();
    }

    onEnable() {
        for (const key in this._recs) {
            const rec = this._recs[key];
            rec && rec.reset();
        }
    }

    setBuffIco() {
        // let types = GlobalEnum.BuffType;
        for (let i = 0; i < 3; i++) {
            let e = GlobalPool.get('buffCd', i);
            e.parent = this.node;
            let cmp = e.getComponent(BuffCd);
            this._recs.push(cmp);
            e.active = false;
        }
    }

    update(dt) {
        for (const key in this._recs) {
            const rec = this._recs[key];
            rec && rec.customUpdate(dt);
        }
    }
}


